package jdk8;

import java.util.ArrayList;

/**
 * @author oldliu
 * @since 1.0
 */
public class Labmda {
    public static void main(String[] args) {
//         (x, y) -> {
//            System.out.println(x);
//            System.out.println(y);
//            return x + y;
//        };
        ArrayList<String> list = new ArrayList<>();
        list.add("zhangsan");
        list.add("lisi");
        list.add("wangwu");
        list.add("zhaoliu");
        //for循环遍历
//        for (String s : list) {
//            System.out.println(s);
//        }
        list.forEach(x->System.out.println(x));


        Runnable r=()->System.out.println("i am runing");
        r.run();

        MyLambda r1=(x,y)->{return x+y;};
        MyLambda r2=(x,y)->{return x*y;};
        System.out.println(r1.add(10,20));
        System.out.println(r2.add(10,20));
    }
}

@FunctionalInterface
interface MyLambda{
    public int add(int a,int b);
}